package com.wordLearning.word.infra.basic.service.impl;

import com.wordLearning.word.infra.basic.dao.FavoriteWordDao;
import com.wordLearning.word.infra.basic.entity.FavoriteWord;
import com.wordLearning.word.infra.basic.entity.Word;
import com.wordLearning.word.infra.basic.service.FavoriteWordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * (FavoriteWord)表服务实现类
 *
 * @author makejava
 * @since 2025-03-22 21:56:59
 */
@Service("favoriteWordService")
public class FavoriteWordServiceImpl implements FavoriteWordService {
    @Resource
    private FavoriteWordDao favoriteWordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param recordId 主键
     * @return 实例对象
     */
    @Override
    public FavoriteWord queryById(Integer recordId) {
        return this.favoriteWordDao.queryById(recordId);
    }

    /**
     * 新增数据
     *
     * @param favoriteWord 实例对象
     * @return 实例对象
     */
    @Override
    public FavoriteWord insert(FavoriteWord favoriteWord) {
        this.favoriteWordDao.insert(favoriteWord);
        return favoriteWord;
    }

    /**
     * 修改数据
     *
     * @param favoriteWord 实例对象
     * @return 实例对象
     */
    @Override
    public FavoriteWord update(FavoriteWord favoriteWord) {
        this.favoriteWordDao.update(favoriteWord);
        return this.queryById(favoriteWord.getRecordId());
    }

    /**
     * 通过主键删除数据
     *
     * @param recordId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer recordId) {
        return this.favoriteWordDao.deleteById(recordId) > 0;
    }

    @Override
    public int deleteByCondition(Integer wordId) {
        return this.favoriteWordDao.deleteByCondition(wordId);
    }

    @Override
    public int countByCondition(FavoriteWord favoriteWord) {
        return this.favoriteWordDao.countByCondition(favoriteWord);
    }

    @Override
    public List<FavoriteWord> queryPage(FavoriteWord favoriteWord, int start, Integer pageSize) {
        return this.favoriteWordDao.queryPage(favoriteWord,start,pageSize);
    }
}
